﻿<sh:SHViewBase x:Class="Mari.SmartHotel.Modules.Foundation.Guests.EditGuestMainView" 
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:clabui="http://Microsoft.Services.Clab/ui/2010/07"
               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
               xmlns:local="clr-namespace:Mari.SmartHotel.Modules.Foundation.Guests"
               xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
               xmlns:sh="http://schemas.smarthotel.it/xaml/presentation"
               xmlns:view="clr-namespace:Microsoft.Services.Clab.UI.Mvvmc.Presentation;assembly=Microsoft.Services.Clab.UI.Mvvmc.Presentation"
               d:DataContext="{d:DesignInstance Type=local:EditGuestViewModel}"
               d:DesignWidth="600"
               mc:Ignorable="d">
    <sh:SHViewBase.Title>
        <StackPanel Orientation="Horizontal">
            <TextBlock>Cliente</TextBlock>
            <TextBlock Text="{Binding Path=Guest.Surname}" />
        </StackPanel>
    </sh:SHViewBase.Title>
    <sh:SHViewBase.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </sh:SHViewBase.Resources>
    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <TabControl>
            <TabItem Header="Dati cliente">
                <GroupBox Header="Dati anagrafici">
                    <Grid HorizontalAlignment="Stretch" 
                          VerticalAlignment="Stretch"
                          ShowGridLines="False">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Label Grid.Row="0" 
                               Width="Auto"
                               Height="Auto"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Content="Cognome:" />
                        <TextBox Grid.Column="1" 
                                 Grid.ColumnSpan="3"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Center"
                                 MaxLength="256"
                                 Text="{Binding Path=Guest.Surname}">
                            <!--
                                <sh:ShellPanesService.HelpMessage>
                                <TextBlock TextWrapping="Wrap">Inserire il cognome del destinatario</TextBlock>
                                </sh:ShellPanesService.HelpMessage>
                            -->
                        </TextBox>
                        <Label Grid.Row="1" 
                               Width="Auto"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Content="Nome: " />
                        <TextBox Grid.Row="1" 
                                 Grid.Column="1"
                                 Grid.ColumnSpan="3"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Center"
                                 MaxLength="256"
                                 Text="{Binding Path=Guest.Name}">
                            <!--
                                <sh:ShellPanesService.HelpMessage>
                                <TextBlock TextWrapping="Wrap">Inserire il nome del destinatario</TextBlock>
                                </sh:ShellPanesService.HelpMessage>
                            -->
                        </TextBox>
                        <Label Grid.Row="2" 
                               Width="Auto"
                               Height="Auto"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Content="Data di nascita:" />
                        <DatePicker Grid.Row="2" 
                                    Grid.Column="1"
                                    SelectedDate="{Binding Path=Guest.DateOfBirth}" />
                        <Label Grid.Row="2" 
                               Grid.Column="2"
                               Width="Auto"
                               Height="Auto"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Content="Sesso:" />
                        <ComboBox Grid.Row="2" 
                                  Grid.Column="3"
                                  DisplayMemberPath="GenderCode"
                                  IsEditable="True"
                                  ItemsSource="{Binding Path=Genders}"
                                  SelectedItem="{Binding Path=Guest.Gender}" />
                        <Label Grid.Row="3" 
                               Width="Auto"
                               Height="Auto"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Content="Nazione di nascita:" />
                        <ComboBox x:Name="cboCountries" 
                                  Grid.Row="3"
                                  Grid.Column="1"
                                  DisplayMemberPath="Name"
                                  IsEditable="True"
                                  ItemsSource="{Binding Path=Countries}"
                                  SelectedItem="{Binding Path=Guest.BirthCountry}" />
                        <Label Grid.Row="4" 
                               Width="Auto"
                               Height="Auto"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Content="Provincia di nascita:" />
                        <ComboBox x:Name="cboDistricts" 
                                  Grid.Row="4"
                                  Grid.Column="1"
                                  DisplayMemberPath="Name"
                                  IsEditable="True"
                                  ItemsSource="{Binding Path=Guest.BirthCountry.Districts}"
                                  SelectedItem="{Binding Path=Guest.BirthCity.District}"
                                  SelectionChanged="cboDistricts_SelectionChanged" />
                        <Label Grid.Row="4" 
                               Grid.Column="2"
                               Width="Auto"
                               Height="Auto"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Content="Comune di nascita:" />
                        <ComboBox Grid.Row="4" 
                                  Grid.Column="3"
                                  DisplayMemberPath="Name"
                                  IsEditable="True"
                                  ItemsSource="{Binding ElementName=cboDistricts, Path=SelectedItem.Cities}"
                                  SelectedItem="{Binding Path=Guest.BirthCity}" />
                        <Label Grid.Row="5" 
                               Width="Auto"
                               Height="Auto"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Content="Città straniera:" />
                        <TextBox Grid.Row="5" 
                                 Grid.Column="1"
                                 Grid.ColumnSpan="3"
                                 Width="Auto"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Center"
                                 Text="{Binding Path=Guest.ForeignCity}" />
                        <Label Grid.Row="6" 
                               Width="Auto"
                               Height="Auto"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Content="C.F.:" />
                        <Button Grid.Row="6" 
                                Grid.Column="1"
                                HorizontalAlignment="Right"
                                Command="{clabui:ActionCommand ActionName=GenerateFiscalCode}">
                            <Image Width="16" Source="/Mari.SmartHotel.Controls;component/Resources/SHMessageBox/Information.png" />
                        </Button>
                        <TextBox Grid.Row="6" 
                                 Grid.Column="1"
                                 Width="Auto"
                                 Margin="0,0,26,0"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Center"
                                 MaxLength="16"
                                 Text="{Binding Path=Guest.CF}" />
                        <Label Grid.Row="6" 
                               Grid.Column="2"
                               Width="Auto"
                               Height="Auto"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Content="P.I.:" />
                        <TextBox Grid.Row="6" 
                                 Grid.Column="3"
                                 Width="Auto"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Center"
                                 MaxLength="20"
                                 Text="{Binding Path=Guest.PI}" />
                        <Label Grid.Row="7" 
                               Width="Auto"
                               Height="Auto"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Content="Telefono:" />
                        <TextBox Grid.Row="7" 
                                 Grid.Column="1"
                                 Width="Auto"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Center"
                                 Text="{Binding Path=Guest.PhoneNumber}" />
                        <Label Grid.Row="7" 
                               Grid.Column="2"
                               Width="Auto"
                               Height="Auto"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Content="E-Mail:" />
                        <TextBox Grid.Row="7" 
                                 Grid.Column="3"
                                 Width="Auto"
                                 HorizontalAlignment="Stretch"
                                 VerticalAlignment="Center"
                                 Text="{Binding Path=Guest.Mail}" />
                        <Label Grid.Row="8" 
                               Width="Auto"
                               Height="Auto"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center"
                               Content="Società:" />
                        <ComboBox Grid.Row="8" 
                                  Grid.Column="1"
                                  DisplayMemberPath="Name"
                                  IsEditable="True"
                                  ItemsSource="{Binding Path=Companies}"
                                  SelectedItem="{Binding Path=Guest.Company}" />
                    </Grid>
                </GroupBox>
            </TabItem>
            <TabItem Header="Documenti d'identità">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <GroupBox Header="Documento d'identità">
                        <Grid ShowGridLines="False">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Label Grid.Row="0" 
                                   Width="Auto"
                                   Height="Auto"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Center"
                                   Content="Tipo:" />
                            <ComboBox Grid.Column="1" 
                                      HorizontalAlignment="Stretch"
                                      VerticalAlignment="Center"
                                      DisplayMemberPath="Name"
                                      IsEditable="True"
                                      ItemsSource="{Binding Path=IdentificationTypes}"
                                      SelectedValue="{Binding Path=CurrentIdentification.IdentificationType, Mode=TwoWay}" />
                            <Label Grid.Column="2" 
                                   Width="Auto"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Center"
                                   Content="Numero: " />
                            <TextBox Grid.Column="3" 
                                     HorizontalAlignment="Stretch"
                                     VerticalAlignment="Center"
                                     MaxLength="50"
                                     Text="{Binding Path=CurrentIdentification.Number}" />
                            <Label Grid.Row="1" 
                                   Width="Auto"
                                   Height="Auto"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Center"
                                   Content="Data di rilascio:" />
                            <DatePicker Grid.Row="1" 
                                        Grid.Column="1"
                                        SelectedDate="{Binding Path=CurrentIdentification.DateOfIssue}" />
                            <Label Grid.Row="1" 
                                   Grid.Column="2"
                                   Width="Auto"
                                   Height="Auto"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Center"
                                   Content="Data di scadenza:" />
                            <DatePicker Grid.Row="1" 
                                        Grid.Column="3"
                                        SelectedDate="{Binding Path=CurrentIdentification.DateOfExpiry}" />
                            <Label Grid.Row="2" 
                                   Width="Auto"
                                   Height="Auto"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Center"
                                   Content="Nazione:" />
                            <ComboBox Grid.Row="2" 
                                      Grid.Column="1"
                                      DisplayMemberPath="Name"
                                      IsEditable="True"
                                      ItemsSource="{Binding Path=Countries}"
                                      SelectedItem="{Binding Path=CurrentIdentification.Country, Mode=TwoWay}" />
                            <Label Grid.Row="3" 
                                   Width="Auto"
                                   Height="Auto"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Center"
                                   Content="Rilasciato da:" />
                            <TextBox Grid.Row="3" 
                                     Grid.Column="1"
                                     Grid.ColumnSpan="3"
                                     Text="{Binding Path=CurrentIdentification.Authority}" />
                            <StackPanel Grid.Row="4" 
                                        Grid.ColumnSpan="4"
                                        HorizontalAlignment="Right"
                                        Orientation="Horizontal">
                                <Button Width="75" 
                                        Margin="5"
                                        Command="{clabui:ActionCommand ActionName=DeleteIdentification}">
                                    Elimina
                                </Button>
                                <Button Width="100" 
                                        Margin="5"
                                        Command="{clabui:ActionCommand ActionName=AddIdentification}">
                                    Aggiungi nuovo
                                </Button>
                            </StackPanel>
                        </Grid>
                    </GroupBox>
                    <GroupBox Grid.Row="1" Header="Documenti acquisiti">
                        <DataGrid AutoGenerateColumns="False" 
                                  IsReadOnly="True"
                                  ItemsSource="{Binding Path=Guest.Identifications}"
                                  SelectedItem="{Binding Path=CurrentIdentification, Mode=TwoWay}">
                            <DataGrid.Columns>
                                <DataGridTextColumn Binding="{Binding Path=IdentificationType.Name}" Header="Tipo" />
                                <DataGridTextColumn Binding="{Binding Path=Number}" Header="Numero" />
                                <DataGridTextColumn Binding="{Binding Path=DateOfIssue, StringFormat=\{0:d\}}" Header="Data Rilascio" />
                                <DataGridTextColumn Binding="{Binding Path=DateOfExpiry, StringFormat=\{0:d\}}" Header="Data Scadenza" />
                                <DataGridTextColumn Binding="{Binding Path=Country.Name}" Header="Nazione" />
                                <DataGridTextColumn Binding="{Binding Path=Authority}" Header="Rliasciato da" />
                            </DataGrid.Columns>
                        </DataGrid>
                    </GroupBox>
                </Grid>
            </TabItem>
            <TabItem Header="Note\Privacy">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <GroupBox Header="Privacy">
                        <ListView ItemsSource="{Binding Path=Guest.PrivacyList}">
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <CheckBox MinWidth="300" 
                                              IsChecked="{Binding Path=Value}"
                                              IsThreeState="True">
                                        <CheckBox.Content>
                                            <StackPanel>
                                                <TextBlock FontWeight="Bold" Text="{Binding Path=Privacy.Name}" />
                                                <TextBlock FontSize="8" Text="{Binding Path=Privacy.Text}" />
                                                <TextBlock Visibility="{Binding Converter={StaticResource BooleanToVisibilityConverter}, Path=Privacy.IsMandatory}">Obbligatorio</TextBlock>
                                            </StackPanel>
                                        </CheckBox.Content>
                                    </CheckBox>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                        </ListView>
                    </GroupBox>
                    <GroupBox Grid.Row="1" Header="Note">
                        <TextBox AcceptsReturn="True" 
                                 AcceptsTab="True"
                                 AutoWordSelection="False"
                                 HorizontalScrollBarVisibility="Auto"
                                 Text="{Binding Path=Guest.Notes}"
                                 TextWrapping="Wrap"
                                 VerticalScrollBarVisibility="Auto" />
                    </GroupBox>
                </Grid>
            </TabItem>
            <TabItem Header="Soggiorni" Visibility="{Binding Path=IsModify, Converter={StaticResource BooleanToVisibilityConverter}}" />
            <TabItem Header="Ricevute" Visibility="{Binding Path=IsModify, Converter={StaticResource BooleanToVisibilityConverter}}" />
        </TabControl>
        <StackPanel Grid.Row="2" 
                    HorizontalAlignment="Right"
                    Orientation="Horizontal">
            <Button Width="75" Margin="5">Annulla</Button>
            <Button Width="75" 
                    Margin="5"
                    Command="{clabui:ActionCommand ActionName=SaveGuest}">
                <Button.Style>
                    <Style TargetType="{x:Type Button}">
                        <Setter Property="Content" Value="Salva" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path=IsModify}" Value="True">
                                <Setter Property="Content" Value="Modifica" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Button.Style>
            </Button>
        </StackPanel>
    </Grid>
</sh:SHViewBase>
